/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GameObject;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;

/**
 *
 * @author Huy
 */
public class ValueBar {
	private Color color;
	private Color colorBack;
	private double value;
	private Rectangle area;

	public ValueBar(Color color, double value, Rectangle area) {
		this.color = color;
		this.value = value;
		this.area = area;
	}
	public ValueBar(Color colorBack,Color color, double value, int x,int y,int w,int h) {
		this.colorBack = colorBack;
		this.color = color;
		this.value = value;
		this.area = new Rectangle(x, y, w, h);
	}
	public void setPosition(int x,int y)
	{
		area.x = x;
		area.y = y;
	}
	
	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public double getValue() {
		return value;
	}

	public void setValue(double value) {
		this.value = value;
	}
	public void setSize(int w,int h)
	{
		area.width = w;
		area.height = h;
	}
	public void draw(Graphics2D g,int x,int y)
	{
		Rectangle rect = new Rectangle(area);
		rect.x += x;
		rect.y += y;
		int w = (int)(rect.width*value);
		g.setColor(colorBack);
		g.fill(rect);
		g.setColor(color);
		rect.width = w;
		g.fill(rect);
	}
}
